package com.freesun.monitor.fs;

import org.csource.common.MyException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;

/**
 * 测试上传
 *
 * @author yangfei
 * @created  2013-12-11
 * @desc  文件上传线程实现
 */
public class MultUploadFastDfs implements Runnable{

    private Logger log = LoggerFactory.getLogger(this.getClass());
    private String clientPath;
    private String localFilePath;

    private FastDfs fastDfs;

    /**
     * @desc 初始化
     * @param clientPath
     * @param localFilePath
     * @param fastDfs
     */
    public MultUploadFastDfs(String clientPath, String localFilePath, FastDfs fastDfs){
        this.clientPath = clientPath;
        this.localFilePath = localFilePath;
        this.fastDfs = fastDfs;
    }

    @Override
    public void run() {

        try {
            this.fastDfs.uploadFile(clientPath,localFilePath);
            log.debug("上传文件:"+localFilePath+"成功!");
        } catch (IOException e) {
            log.debug("上传文件:"+localFilePath+"失败!");
            e.printStackTrace();
        } catch (MyException e) {
            log.debug("上传文件:"+localFilePath+"失败!");
            e.printStackTrace();
        }
    }
}